from bs4 import BeautifulSoup

html_doc = '''
<!doctype html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta name="viewport" content="user-scalable=no, initial-scale=1.0, width=device-width" />
    <meta name="apple-mobile-web-app-status-bar-style" content="grey" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <title>有道翻译</title>
    <link rel="shortcut icon" href="//shared.ydstatic.com/dict/v5.15/images/icon.png" type="image/x-icon" />
    <link rel="apple-touch-icon" href="//shared.ydstatic.com/dict/v5.15/images/icon.png" />

    <!-- <link rel="stylesheet" type="text/css" href="../../styles/global-min.css">
    <link rel="stylesheet" type="text/css" href="../../styles/p-fanyi-min.css"> -->
    <style type="text/css">
        html {
            -webkit-text-size-adjust: none
        }

        body {
            background-color: #fff;
            font-family: "Times New Roman", Times, serif;
            font-size: 14px;
            line-height: 21px;
            color: #313131
        }

        body,
        div,
        h1,
        h2,
        h3,
        h4,
        h5,
        input,
        li,
        ol,
        p,
        textarea,
        ul {
            margin: 0;
            padding: 0;
            outline: 0
        }

        li,
        ol,
        ul {
            list-style: none
        }

        input {
            -webkit-appearance: none
        }

        a {
            color: #138bff;
            text-decoration: none;
            cursor: pointer
        }

        a:active,
        a:hover {
            color: #138bff
        }

        strong {
            color: #c50000;
            word-wrap: break-word
        }

        #bd {
            background: #f4f4f4;
            padding: 7px 0
        }

        .p-index_entry #bd {
            background: #fff;
            padding: 0
        }

        .p-index #hd {
            border-bottom: 1px solid #e8e8e8
        }

        .content-wrp {
            margin: 7px
        }

        #ft {
            padding: 7px 0;
            background: #fff
        }

        .empty-content {
            background: #FFF;
            padding: 35px 7px;
            vertical-align: middle
        }

        .btn {
            border-radius: 4px;
            -webkit-border-radius: 4px;
            -moz-border-radius: 4px;
            -o-border-radius: 4px;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            -o-user-select: none;
            user-select: none;
            padding: 11px 35px;
            display: inline-block;
            cursor: pointer;
            white-space: nowrap;
            vertical-align: top;
            border: 1px solid #076ccc;
            background: -webkit-gradient(linear, left top, left bottom, from(#0082ff), to(#0082ff));
            background: -webkit-linear-gradient(top, #0082ff, #0082ff);
            background: -moz-linear-gradient(top, #0082ff, #0082ff);
            background: -o-linear-gradient(top, #0082ff, #0082ff);
            font-size: 14px
        }

        .nav-label {
            background-color: #fff;
            border-bottom: 1px solid #e0e0e0;
            display: table;
            width: 100%
        }

        .nav-label:after,
        .nav-label:before {
            content: " ";
            display: table
        }

        .nav-label:after {
            clear: both
        }

        .nav-label .logo {
            display: table-cell;
            width: 1%;
            vertical-align: middle;
            padding: 11px 7px
        }

        .nav-label .nav {
            display: table;
            width: 100%;
            text-align: center
        }

        .nav-label .nav li {
            display: table-cell
        }

        .nav-label .nav li.active {
            border-bottom: 3px solid #0082ff
        }

        .nav-label .nav a {
            display: inline-block;
            padding: 11px 7px;
            color: #646464;
            position: relative
        }

        .search-area {
            background: #fff;
            position: relative
        }

        .search-bar {
            position: relative;
            display: table;
            border-collapse: separate;
            width: 100%;
            padding: 11px 7px 7px;
            box-sizing: border-box;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box
        }

        .search-area .clearInput {
            position: absolute;
            top: 14px;
            right: 57px;
            width: 34px;
            height: 0;
            padding-top: 34px;
            overflow: hidden;
            background: url(//shared.ydstatic.com/dict/youdaowap/changeImg/close.png) no-repeat 0 0;
            background-size: 100%;
            display: none
        }

        .search-bar .form-control {
            display: table-cell;
            padding: 11px 7px;
            border: 1px solid #d9d9d9;
            border-top-color: silver;
            background-image: none;
            vertical-align: top;
            width: 99%;
            font-size: 14px;
            border-radius: 0
        }

        .search-bar .input-group-btn {
            display: table-cell;
            width: 1%;
            vertical-align: top
        }

        .search-bar .btn {
            border-radius: 0 4px 4px 0;
            -webkit-border-radius: 0 4px 4px 0;
            -moz-border-radius: 0 4px 4px 0;
            -o-border-radius: 0 4px 4px 0;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            -o-user-select: none;
            user-select: none;
            padding: 11px 25px;
            display: inline-block;
            cursor: pointer;
            white-space: nowrap;
            vertical-align: top;
            border: 1px solid #076ccc;
            background: -webkit-gradient(linear, left top, left bottom, from(#0082ff), to(#0082ff));
            background: -webkit-linear-gradient(top, #0082ff, #0082ff);
            background: -moz-linear-gradient(top, #0082ff, #0082ff);
            background: -o-linear-gradient(top, #0082ff, #0082ff);
            background: #0082ff url(//shared.ydstatic.com/dict/youdaowap/changeImg/search.png) no-repeat 13px 6px;
            box-sizing: border-box;
            -webkit-box-sizing: border-box;
            font-size: 14px;
            background-size: 50%
        }

        .search-bar .selectedLang {
            display: table-cell;
            background: #fff;
            border: 1px solid #d9d9d9;
            border-right: 0;
            border-top-color: silver;
            border-radius: 4px 0 0 4px;
            -webkit-border-radius: 4px 0 0 4px;
            -moz-border-radius: 4px 0 0 4px;
            -o-border-radius: 4px 0 0 4px;
            color: #313131;
            width: 1%;
            vertical-align: middle
        }

        .search-bar .selectedLang span {
            display: inline-block;
            width: 30px;
            padding: 0 7px
        }

        .search-area .lang-select-list {
            position: absolute;
            background: #fff;
            border: 1px solid #d9d9d9;
            left: 7px;
            top: 51px;
            display: none
        }

        .search-area .lang-select-list li {
            padding: 7px 22px;
            border-bottom: 1px solid #d9d9d9;
            -webkit-tap-highlight-color: red
        }

        .page {
            border-radius: 2px;
            -webkit-border-radius: 2px;
            -moz-border-radius: 2px;
            -o-border-radius: 2px;
            border: 1px solid #e1e1e1;
            background: #fff;
            display: block;
            text-align: center;
            color: #313131
        }

        .page a {
            width: 49%;
            display: inline-block;
            text-align: center;
            padding: 11px 0
        }

        .copy {
            text-align: center;
            font-size: 12px;
            color: #b2b2b2
        }

        .copy a {
            margin: 0 7px;
            color: #8f9dae
        }

        #suggest {
            position: absolute;
            top: 53px;
            width: 100%;
            padding: 0 7px;
            box-sizing: border-box;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box
        }

        #suggest .container {
            border: 1px solid #D9D9D9;
            border-top: 0;
            border-bottom: 0
        }

        #suggest .container li {
            padding: 7px 0;
            border-bottom: 1px solid #D9D9D9;
            overflow: hidden;
            -webkit-text-overflow: ellipsis;
            text-overflow: ellipsis;
            white-space: nowrap;
            background: #fff;
            -webkit-tap-highlight-color: #ff0
        }

        #suggest .close {
            border: 1px solid #D9D9D9;
            box-sizing: border-box;
            width: 100%;
            border-top: 0;
            background: #fff
        }

        #suggest .close a {
            display: inline-block;
            width: 100%;
            padding: 7px 0
        }

        #suggest .container li:active {
            background: #D8D8D8
        }

        #suggest .container:last-child {
            border-bottom: 0
        }

        #suggest .container strong {
            margin: 0 7px;
            color: #313131
        }

        .translate-area .original {
            margin: 0 0 7px;
            height: 110px
        }

        .translate-area .original textarea {
            width: 100%;
            height: 110px;
            border: 1px solid #E1E1E1;
            resize: none;
            padding: 11px;
            box-sizing: border-box;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box
        }

        .translate-area .select {
            margin: 0 7px 7px
        }

        .translate-area .select select {
            height: 38px;
            width: 140px;
            border: 1px solid #a6d7ff;
            appearance: none;
            -webkit-appearance: none;
            -moz-appearance: none;
            background: #ecf6ff url(//shared.ydstatic.com/dict/youdaowap/icon/down.png) no-repeat 115px 8px
        }

        .translate-area .select option {
            height: 40px
        }

        .translate-area .select .blue-btn {
            border-radius: 4px;
            -webkit-border-radius: 4px;
            -moz-border-radius: 4px;
            -o-border-radius: 4px;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            -o-user-select: none;
            user-select: none;
            display: inline-block;
            cursor: pointer;
            white-space: nowrap;
            vertical-align: top;
            border: 1px solid #a6d7ff;
            background: #ecf6ff url(//shared.ydstatic.com/dict/youdaowap/icon/icon.png) no-repeat 24px 6px;
            padding: 11px 21px 11px 54px;
            float: right
        }

        .translate-area .generate {
            border-top: 1px solid #e1e1e1;
            background: #fff;
            padding: 11px 7px 0;
            min-height: 110px
        }

        .translate-area .generate .tip {
            color: #999
        }

        #clearTextarea {
            display: inline-block;
            padding: 10px
        }

        .fanyi-dl {
            display: block;
            padding: 7px;
            border: 1px solid #E1E1E1;
            background-color: #FAFAFA;
            font-size: 12px
        }

        html {
            height: 100%;
        }

        body.from-chuansongmen {
            height: 100%;
            background: #f4f4f4;
        }

        .from-chuansongmen .tab {
            width: 100%;
            height: 38px;
        }

        .from-chuansongmen .tab img {
            width: 20px;
            height: 20px;
            margin: 14px 4px 0 25px;
            display: block;
            float: left;
        }

        .from-chuansongmen .tab h5 {
            height: 38px;
            font-size: 12px;
            color: #999;
            text-align: left;
            line-height: 50px;
        }

        .from-chuansongmen #ft {
            display: none;
        }
    </style>
</head>

<body>
    <div id="doc2">
        <div id="hd">
            <div class="nav-label">
                <span class="logo"><a href="/"><img src="//shared.ydstatic.com/images/mobile/logo-mobile-whole.gif" width="71" height="16" alt="有道"></a></span>
                <ul class="nav">

                    <li><a class="pr-link-a" href="/dict?q=">词典</a></li>

                    <li class="active"><a href="/translate">翻译</a></li>
                    <li><a
                            href="/redirect?keyfrom=youdaowap.index&url=http%3a%2f%2fm.note.youdao.com%2fnoteproxy%2flogin%3fkeyfrom%3dhome.m">笔记</a>
                    </li>
                </ul>
            </div>
        </div>
        <div id="bd">
            <div class="translate-area">
                <form action="/translate" method="POST" name="translate">
                    <div class="content-wrp original">
                        <textarea id="inputText" name="inputtext">中国</textarea>
                    </div>
                    <div class="select">
                        <select class="convert" name="type">
                    	                        <option value="AUTO" selected="selected"> 自动检测 </option>
                                                                        <option value="ZH_CN2EN"> 中译英 </option>
                                                                        	<option value="ZH_CN2JA"> 中译日 </option>
                                                                        	<option value="ZH_CN2KR"> 中译韩 </option>
                                                                        	<option value="ZH_CN2FR"> 中译法 </option>
                                                                        	<option value="ZH_CN2RU"> 中译俄 </option>
                                                                        	<option value="ZH_CN2SP"> 中译西 </option>
                                                                        	<option value="EN2ZH_CN"> 英译中 </option>
                                                                        	<option value="JA2ZH_CN"> 日译中 </option>
                                                                        	<option value="KR2ZH_CN"> 韩译中 </option>
                                                                        	<option value="FR2ZH_CN"> 法译中 </option>
                                                                        	<option value="RU2ZH_CN"> 俄译中 </option>
                                                                        	<option value="SP2ZH_CN"> 西译中 </option>
                                            </select>
                        <a id="clearTextarea" href="#">清空</a>
                        <input class="blue-btn" type="submit" value="翻译">
                    </div>
                </form>
                <div class="generate">
                    <p class="tip">译文</p>
                    <ul id="translateResult">
                        <li>China</li>
                    </ul>
                </div>
            </div>
        </div>
        <div id="ft">
            <div class="content-wrp">
                <a id="toRengong" class="fanyi-dl"
                    href="http://f.youdao.com/m?vendor=fanyimobile">有道人工翻译&nbsp;-&nbsp;24小时不打烊</a>
            </div>
            <p class="copy"> <a href="/">有道首页</a>|<a href="/fankui">反馈意见</a>|
                <a href="http://fanyi.youdao.com/?mct=1&keyfrom=translate.m">切换到PC版</a>
            </p>
            <p class="copy">&copy;2015&nbsp;公司&nbsp;京ICP证080268号</p>
            <script type="text/javascript" charset="utf-8">
                var Suggest=function(t,n){if(0===t.length)throw new Error("输入元素不存在");this.el=t,this.init(n)},$=function(t){return document.getElementById(t)},trim=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/gi,"")},$s={newid:0},sugCount=0,current$s=0,updateId=function(){return $s.newid=sugCount++ + +new Date},currentInput=null;Suggest.prototype={init:function(t){this.initContainer(t),this.initData(t),this.initInput(t)},initContainer:function(t){var n=this,e=t.suggestContainer,i=t.suggestId,a=document.createElement("div");a.id=i,a.class=i,a.innerHTML='<ul class="container"></ul>',a.style.display="none",e.appendChild(a),n.el.addEventListener("focus",function(t){currentInput=t.target.value}),$("selectedLang").addEventListener("click",function(){n.close(t)},!1)},initData:function(t){var n=this;n.getData="function"==typeof t.data?function(n,e){t.data(n,e)}:t.data.length>0?function(n,e){e(n,t.data,t)}:function(n){n(t.data)}},fetchData:function(t){var n=50,e=this;window.clearTimeout(e.delay),current$s=updateId(),e.delay=window.setTimeout(function(){var n=e.el.value;trim(n)!==trim(currentInput)&&(currentInput=n,e.getData(n,function(n,i){current$s===$s.newid&&e.initItem(n,i,t)}))},n)},initItem:function(t,n,e){var i=this,a="";if(""===trim(t))return void i.close(e);for(var u=0;u<n.length;u++)a+='<li class="item">'+e.generateItem(t,n[u])+"</li>";$(e.suggestId).style.display="block",document.querySelector(".container").innerHTML=a,$(e.suggestId).addEventListener("click",function(t){"item"===t.target.className&&(e.clickItemCallback(t),i.close(e))},!1),$(e.suggestId).addEventListener("touchstart",function(t){if("item"===t.target.className){var n=t.target;e.touchstartItem(n)}},!1),$(e.suggestId).addEventListener("touchend",function(t){if("item"===t.target.className){var n=t.target;e.touchendItem(n)}},!1)},initInput:function(t){var n=this;n.el.addEventListener("input",function(e){n.fetchData(t),e.stopPropagation()},!1)},close:function(t){updateId(),$(t.suggestId).style.display="none"}};    __rl_npid="YoudaoWap";var $=function(e){return document.getElementById(e)},trim=function(e){return String.prototype.trim?e.trim():e.replace(/^\s+|\s+$/gi,"")},toggle=function(e){for(var t,n=0,o=e.length;o>n;n++)if(t=e[n],t.style){var i=window.getComputedStyle(t,null).getPropertyValue("display");"none"===i?t.style.display="block":"block"===i&&(t.style.display="none")}},addClassName=function(e,t){if(e){for(var n=0,o=e.className.split(" "),i=o.length,a=[];i>n;n++)""!==trim(o[n])&&a.push(o[n]);return a.push(t),a.join(" ")}},removeClassName=function(e,t){if(e){for(var n=0,o=e.className.split(" "),i=o.length,a=[];i>n;n++)""!==trim(o[n])&&trim(o[n])!==t&&a.push(o[n]);return a.join(" ")}},parseXml=function(e){for(var t=0,n=[],o=e.getElementsByTagName("item");t<o.length;t++){for(var i=o[t].childNodes,a=[],r=0;r<i.length;r++)i[r].nodeType&&1===i[r].nodeType&&a.push(i[r].childNodes[0].nodeValue);n.push({title:a[0],explain:a[1]})}return n},initLangSel=function(){var e=document.querySelectorAll(".lang-select-list"),t=document.querySelector(".lang-select-list"),n={eng:"中英",fr:"中法",jap:"中日",ko:"中韩"},o=function(e){var o,i="https://m.youdao.com/dict?le=";"li"===e.target.nodeName.toLowerCase()&&(o=e.target.getAttribute("data-value"),$("inputLang").value=o,e.target.style.background="#fff",$("selectedLang").querySelector("span").innerHTML=n[o],t.style.display="none",""!==trim($("formInput").value)&&(window.location.href=i+o+"&q="+$("formInput").value)),e.stopPropagation()};$("selectedLang").addEventListener("click",function(t){toggle(e),t.stopPropagation(),t.preventDefault()},!1),t.addEventListener("click",function(e){o(e)},!1),t.addEventListener("touchstart",function(e){e.preventDefault(),e.stopPropagation(),"li"===e.target.nodeName.toLowerCase()&&(e.target.style.background="#e4efff")},!1),t.addEventListener("touchend",function(e){o(e),e.stopPropagation()},!1),document.addEventListener("click",function(){t.style.display="none"},!1)};document.addEventListener("DOMContentLoaded",function(){function e(e,t){var n,o,i,a,l=document.body;n=document.createElement("div"),n.className="shim",l.appendChild(n),n.style.height=document.documentElement.scrollHeight+"px",o=document.createElement("div"),o.className="overlay",i=document.createElement("p"),i.innerHTML=e,a=document.createElement("p"),a.className="confirm",a.innerHTML="好",o.appendChild(i),o.appendChild(a),l.appendChild(o);var c=document.documentElement.scrollTop||document.body.scrollTop;document.addEventListener("orientationchange",function(){c=document.documentElement.scrollTop||document.body.scrollTop,o.style.top=Math.ceil((window.innerHeight-o.offsetHeight)/2)+c+"px"},!1),o.style.top=Math.ceil((window.innerHeight-o.offsetHeight)/2)+c+"px",document.addEventListener("touchmove",r,!1),o.onclick=function(){if(l.removeChild(o),l.removeChild(n),document.removeEventListener("touchmove",r,!1),"function"==typeof t)try{t()}catch(e){}}}var t=$("formInput"),n=function(){document.body?document.body.scrollTop=0:document.documentElement.scrollTop=0,document.body.style.height=window.innerHeight+"px",document.addEventListener("orientationchange",function(){document.body.style.width=window.innerWidth+"px",document.body.style.height=window.innerHeight+"px"},!1)};if(n(),t){var o=$("clearInput"),i=function(){var e=t.value;""!==trim(e)?o.style.display="inline-block":o.style.display="none"};if(i(),$("formSubmit").onsubmit=function(e){var t=$("formInput").value;""===trim(t)&&e.preventDefault()},t.addEventListener("keyup",function(){i()},!1),!!o&&o.addEventListener("click",function(e){t.value="",this.style.display="none",document.querySelector(".lang-select-list").style.display="none",$("suggest").style.display="none",e.preventDefault()},!1),document.querySelector("body").className.indexOf("p-dict")>=0||document.querySelector("body").className.indexOf("p-index_entry")>=0){var a;new Suggest(document.getElementById("formInput"),{suggestContainer:document.querySelector(".search-area"),suggestId:"suggest",data:function(e,t){a=""==$("inputLang").value?"eng":$("inputLang").value;var n="https://dict.youdao.com/suggest?type=DESKDICT&num=4&q="+e+"&ver=2.0&le="+a,o=new XMLHttpRequest;o.onreadystatechange=function(){if(4==o.readyState){var n=new DOMParser,i=n.parseFromString(o.response,"text/xml"),a=parseXml(i);t(e,a)}},o.open("get",n,!0),o.send(null)},generateItem:function(e,t){return"<strong>"+t.title+"</strong>"+t.explain},clickItemCallback:function(e){var t="https://m.youdao.com/dict?q=";window.location.href=t+e.target.querySelector("strong").innerText+"&le="+a},touchstartItem:function(e){e.style.background="#e4f4ff"},touchendItem:function(e){e.className="item";var t="https://m.youdao.com/dict?q=";window.location.href=t+e.querySelector("strong").innerText}});initLangSel()}}document.addEventListener("click",function(e){"pr-link-a"==e.target.className&&t&&(e.target.href=e.target.href+t.value)},!1),!!$("report_feedback")&&$("report_feedback").addEventListener("submit",function(){e("感谢您的反馈",function(){$("issueDes").value="",$("questionDes").value="",$("emailDes").value=""})},!1);var r=function(e){e.preventDefault()}},!1);
            </script>
            <script type="text/javascript" charset="utf-8">
                /*!
 * linkToManual.js 0.0.1
 */

(function(a){var b={};(function(){var a=0;var c=1;var d=2;b.isLangVaildable=function(b){var c=C(b);var d=c[0];if(d===a){return false}if(d==="auto"){return true}return true};function e(a){var b=a.charCodeAt(0);if(a==="　"){return true}else if(b<=32||b===255){return true}else{return false}}var f=[["'","‘","’"],['"',"“","”"],[",","，"],[".","。"],[";","；"],[":","："],["、"],["·"],["/","／"],["?","？"],["\\","＼"],["|","｜"],["`"],["~","～"],["!","！"],["@","＠"],["#","＃"],["$","＄"],["¥","￥"],["%","％"],["^","＾","…"],["&","＆"],["_"],["(",")"],["（","）"],["[","]"],["［","］"],["{","}"],["<",">"],["+","＋"],["-","－"],["*","＊","×"],["÷"],["=","＝"]];var g=[[10078,12301,12303,12318,65379],[12305,12309,12311,12313,12315],[8250,12297,12299]];var h=["，","。","？","：","（","）","【","】","￥","、","·"];var i={};var j={};for(var k=0;k<f.length;k++){for(var l=0;l<f[k].length;l++){i[f[k][l].charCodeAt(0)]=true}}for(var k=0;k<g.length;k++){for(var l=0;l<g[k].length;l++){i[g[k][l]-1]=true;i[g[k][l]]=true}}for(var k=0;k<h.length;k++){j[h[k]]=true}function m(a){return i[a.charCodeAt(0)]===true}function n(a){return j[a]===true}var o=[[33,47],[58,64],[91,96],[123,126]];function p(a){var b=a.charCodeAt(0);for(var c=0;c<o.length;c++){if(b>=o[c][0]&&b<=o[c][1])return true}return false}var q=[48,57];var r=[65296,65305];function s(a){var b=a.charCodeAt(0);if(b>=q[0]&&b<=q[1]||b>=r[0]&&b<=r[1])return true;return false}var t=[65,90];var u=[97,122];var v=[65313,65338];var w=[65345,65370];function x(a){var b=a.charCodeAt(0);if(b>=t[0]&&b<=t[1]||b>=u[0]&&b<=u[1]||b>=v[0]&&b<=v[1]||b>=w[0]&&b<=w[1])return true;return false}var y=[19968,40959];var z=[13312,19903];var A=[63744,64255];function B(a){var b=a.charCodeAt(0);if(b>=y[0]&&b<=y[1]||b>=z[0]&&b<=z[1]||b>=A[0]&&b<=A[1])return true;return false}function C(b){var f=[];var g=[];var h=0;var i=0;var j=0;var k=0;var l=false;var o=false;var p=true;var q=false;for(var r=0,t=b.length;r<t;r++){var u=b.charAt(r);var v=false;var w=false;if(e(u)){v=w=true;p=true;q=false}else if(m(u)){if(n(u)){j++;p=true;q=false}else if(!l&&!o&&p){j++;q=true;p=false}}else if(x(u)){if(!l&&!o){l=true}p=false;if(q){q=false;j--}}else if(s(u)){if(!o&&!l){o=true}p=false;if(q){q=false;j--}}else if(B(u)){v=w=true;h++;p=true;q=false}else{v=w=true;i++;p=true;q=false}if(l&&(v||r==t-1)||o&&(w||r==t-1)){var y=r;if(y==t-1){y=r+1}var z=b.substring(k,y);if(l){f[f.length]=z}else if(o){g[g.length]=z}if(l||o){k=r}l=false;o=false}if(v&&w){k=r+1;l=false;o=false}}var A=g.length;var C=f.length;var D=C+h;var E=D+A;if(D==0){C=A;D=A;E=A}var F=E+i;var G=i/F;if(G>=.4)return[a,0];var H=C/D;if(H>=.7){return[c,F+j]}var I=h/D;if(I>=.7)return[d,F+j];return[a,0]}})();(function(){document.addEventListener("DOMContentLoaded",function(){var a=$("toRengong");a.onclick=function(a){var c=this;if($("inputText").value!==""&&b.isLangVaildable($("inputText").value)){c.href=c.href+"&text="+encodeURIComponent($("inputText").value)}}},false)})()})(undefined);        
            </script>
        </div>
    </div>
    <!-- <script src="https://c.youdao.com/market/banner/banner-mod.js"></script>
<script src="https://c.youdao.com/market/new_banner.js"></script> -->

    <script type="text/javascript">
        document.addEventListener('DOMContentLoaded', function () {
    var clearTextareaBtn = $('clearTextarea')
    !!clearTextareaBtn && clearTextareaBtn.addEventListener('click', function (e){
            document.querySelectorAll('.original textarea')[0].value = '';
            $('translateResult').innerHTML = '';
            e.preventDefault();
    }, false);
}, false);
    </script>
</body>

</html>
'''


# 解析html页面的译文，仅适用于有道翻译页面
def query_translation(html_page):
    # 转化 html 页面
    soup = BeautifulSoup(html_page, 'html.parser')
    # 遍历所有的div标签
    for div in soup.body.div.find_all('div'):
        # 用来搜寻 class = 'generate' 这个属性
        temp = ''
        try:
            # 查找是否有 class 这个元素，没有找到抛出异常
            temp = div['class'][0]
        except Exception as e:
            # 不做处理，进行下一个判断
            pass
        # 找到目标 div，接着找到目标 li，找到 li 中的 译文
        if "generate" == temp:
            li = div.ul.li
            text = li.text
            return text


result = query_translation(html_doc)
print(result)
